package com.gitee.swsk33.demoserviceuser.service.impl;

import com.gitee.swsk33.demoentity.dataobject.User;
import com.gitee.swsk33.demoentity.model.Result;
import com.gitee.swsk33.demoserviceuser.dao.UserDAO;
import com.gitee.swsk33.demoserviceuser.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

	@Autowired
	private UserDAO userDAO;

	@Override
	public Result<User> getById(int id) {
		User getUser = userDAO.selectOneById(id);
		if (getUser == null) {
			return Result.resultFailed("用户不存在！");
		}
		return Result.resultSuccess("查找用户成功！", getUser);
	}

	@Override
	public Result<List<User>> getAll() {
		List<User> users = userDAO.selectAll();
		return Result.resultSuccess("查找完成！", users);
	}

}